<?php

namespace app\api\controller\home;

use think\Controller;
use think\Request;

class Home extends Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->ProductTypeModel = model('Product.ProductType');
        $this->ProductModel = model('Product.Product');
    }

    public function index()
    {
        // 分类
        $TypeList = model('Product.ProductType')->order('weigh', 'desc')->limit(8)->select();
        $type = model('Product.ProductType')->order('weigh')->select();

        $NewList = model('Product.Product')->where(['flag' => 1])->limit(4)->select();
        $HotList = model('Product.Product')->where(['flag' => 2])->limit(6)->select();

        $data = [
            'TypeList' => $TypeList,
            'NewList' => $NewList,
            'HotList' => $HotList,
            'type' => $type
        ];
        // halt($type);
        $this->success('查询成功', null, $data);
    }

    // 轮播图
    public function banner () {
        $list = model('Product.Product')->where(['flag' => 3])->order('id','desc')->limit(5)->select();
        $this->success('查询成功',null,$list);
    }

}
